package com.lucene.service.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lucene.dao.GoodDetailsDao;
import com.lucene.dao.LuceneDao;
import com.lucene.model.GoodDetails;
import com.lucene.service.IGoodService;

@Service
public class GoodService implements IGoodService {
	
	  @Autowired
	    private GoodDetailsDao goodDetailsDao;


	    public List<GoodDetails> findGoodByClassifyName(String ClassifyName) throws Exception {
	        return null;
	    }
	    private LuceneDao luceneDao=new LuceneDao();
	    public List<GoodDetails> findIndex(String keyword, int start, int row) {
//	        LuceneDao luceneDao = new LuceneDao();
	        System.out.print("luceneDao       "+luceneDao);
	        List<GoodDetails> goodDetailsList;
	        try {
	            long start2 = System.nanoTime();
	            goodDetailsList = luceneDao.findIndex(keyword, start, row);
	            long time = System.nanoTime() - start2;
	            System.out.println("测试索引耗时！！！！"+time);
	            return goodDetailsList;
	        } catch (Exception e) {
	            e.printStackTrace();
	        }
	        return null;
	    }

	    public GoodDetails findGoodAllDetailsById(String goodId) {
	        GoodDetails goodDetails = goodDetailsDao.findGoodDetailsById(goodId);
	        return goodDetails;
	    }

	    public List<GoodDetails> getGoodList(String location) {
	        List<GoodDetails> goodList= goodDetailsDao.findGoods(location);
	        System.out.println(goodList.toString());
	        return goodList;
	    }

	    public List<Integer> methodOfWarn(List<GoodDetails> goodDetailsList) throws Exception {
	        return null;
	    }

}
